import math
import os
import random
import re
import sys
from math import gcd
from math import sqrt
from collections import Counter
a,b = list(map(int,input().split()))
x,y,z = list(map(int,input().split()))
p = max(0,2*x+y-a)
q = max(0,3*z+y-b)
print(p+q)
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
optimize();
long long int a,b;
cin>>a>>b;
long long int x,y,z;
cin>>x>>y>>z;
long long int bl,ye;
ye=x*2;
ye+=y;
bl=y+z*3;
long long int c,d;
if(ye<=a)c=0;
else c=ye-a;
if(bl<=b)d=0;
else d=bl-b;
//cout<<c<<endl<<d<<endl;
cout<<c+d<<endl;
return 0;
}
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |